enum EventType {
    Mouse,
    Keyboard
}

interface Event {
    timestamp:number
}

interface MouseEvent extends Event {
    x1:number
    y1:number
}

interface KeyEvent extends Event {
    KeyCode:number
}

function listenEvent(eventType:EventType,handler:(n:Event)=>void){

}

listenEvent(EventType.Mouse,(e:Event)=> console.log((<MouseEvent>e).x1)+','+(<MouseEvent>e).y1)

// 此时传入的 e 的类型是number类型的 但是函数中接受的类型是Event 类型的
listenEvent(EventType.Mouse, (e: number) => console.log(e));
